package com.yupi.springbootinit.service;

import com.yupi.springbootinit.common.ErrorCode;
import com.yupi.springbootinit.exception.BusinessException;
import com.yupi.yucongming.dev.client.YuCongMingClient;
import com.yupi.yucongming.dev.common.BaseResponse;
import com.yupi.yucongming.dev.model.DevChatRequest;
import com.yupi.yucongming.dev.model.DevChatResponse;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 28993
 */
@Service
public class AIMagger {

	@Resource
    private YuCongMingClient yuCongMingClient;

	public String doChat(Long biModelId,String message){
		DevChatRequest devChatRequest = new DevChatRequest();
		devChatRequest.setModelId(biModelId);
		devChatRequest.setMessage(message);
		BaseResponse<DevChatResponse> devChatResponseBaseResponse = yuCongMingClient.doChat(devChatRequest);
		DevChatResponse data = devChatResponseBaseResponse.getData();
		if (data == null) {
           throw new  BusinessException(ErrorCode.SYSTEM_ERROR,"Ai分析数据失败");
		}
		return data.getContent();
	}

}
